/**
 * 
 */
package com.school.adminServlet.cmd;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.school.dao.AdminManagerDao;
import com.school.dao.AdminManagerDaoImpl;

/**
 * @author KK
 *
 */
public class ScheduleDateFormCommand implements AdminCommand {

	/* (non-Javadoc)
	 * @see com.school.adminServlet.cmd.AdminCommand#processRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.ServletConfig)
	 */
	public static Logger log = Logger.getLogger(ScheduleDateFormCommand.class.getSimpleName());
	@Override
	public void processRequest(HttpServletRequest req,
			HttpServletResponse resp, ServletConfig config)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		String dt = req.getParameter("schedule_date");			System.out.println(dt);
		String examdt[] = req.getParameterValues("schedule_exam");
		String interviewdt[] = req.getParameterValues("schedule_interview");
		if(((req.getParameterValues("schedule_exam")!=null)&&(req.getParameterValues("schedule_exam")==null))||((req.getParameterValues("schedule_exam")==null)&&(req.getParameterValues("schedule_exam")!=null)))
		{
			System.out.println("Please select atleast one student--------------kk");
		}
		else
		{
				for(int i=0;i<examdt.length;i++)		{System.out.println(examdt[i]);	}
				for(int j=0;j<interviewdt.length;j++)	{System.out.println(interviewdt[j]);}
			
			AdminManagerDao ad11 = new AdminManagerDaoImpl();
			AdminManagerDao ad12 = new AdminManagerDaoImpl();
			
			if(ad12.setInterviewDtNewlyRegistered(dt, interviewdt) == true)
			{
				req.setAttribute("newsSuccess", true);
			}
			else if(ad11.setExamDtNewlyRegistered(dt, examdt) == true)
			{
				req.setAttribute("newsSuccess", true);
			}
			else
			{
				req.setAttribute("newsSuccess", false);		//set error page true
			}
		}
		
		req.setAttribute("info", true);
		req.setAttribute("insertNewsForm1", false);
		req.setAttribute("adminProfile", false);
		req.setAttribute("viewAllRegistered", false);
		req.setAttribute("scheduleExam", false);
		req.setAttribute("publishExamResult", false);
		req.setAttribute("scheduleInterview", false);
		req.setAttribute("publishFinalResult", false);

		req.setAttribute("profileManage", false);
		req.setAttribute("admission", false);
		req.setAttribute("examManage", false);
		req.setAttribute("timeTable", false);
		req.setAttribute("attendance", false);
		req.setAttribute("studentDetails", false);
		req.setAttribute("manageNews", false);
		
		RequestDispatcher dispatcher = req.getRequestDispatcher("/admin_home.jsp");
		dispatcher.forward(req, resp);
		
		System.out.println("exited processRequest()+kkkkkkkkkkkkk");
		

	}

}
